<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button id="btn">按钮</button>
</body>
<script>
  const btn = document.querySelector("#btn")
  const person = {
    name: "lily",
    age: 18,
    sex: "男",
  };
  const proxyPerson = new Proxy(person, {
    get(target, property) {
      console.log("被获取了");
      return target[property]
    },
    set(target, property, value) {
      console.log("被设置了");
      target[property] = value
    }
  })
  btn.onclick = function () {
    delete proxyPerson.age
    console.log(person);
  }
</script>

</html>